package com.ruoyi.project.game.recommendhistory.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.game.recommendhistory.domain.RecommendHistory;
import com.ruoyi.project.game.recommendhistory.service.IRecommendHistoryService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 热搜设置Controller
 * 
 * @author shixiangwen
 * @date 2020-02-24
 */
@Controller
@RequestMapping("/game/recommendhistory")
public class RecommendHistoryController extends BaseController {
	private String prefix = "game/recommendhistory";

	@Autowired
	private IRecommendHistoryService recommendHistoryService;

	@RequiresPermissions("game:recommendhistory:view")
	@GetMapping()
	public String recommendhistory() {
		return prefix + "/recommendhistory";
	}

	/**
	 * 查询热搜设置列表
	 */
	@RequiresPermissions("game:recommendhistory:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(RecommendHistory recommendHistory) {
		startPage();
		List<RecommendHistory> list = recommendHistoryService.selectRecommendHistoryList(recommendHistory);
		return getDataTable(list);
	}

	/**
	 * 导出热搜设置列表
	 */
	@RequiresPermissions("game:recommendhistory:export")
	@PostMapping("/export")
	@ResponseBody
	public AjaxResult export(RecommendHistory recommendHistory) {
		List<RecommendHistory> list = recommendHistoryService.selectRecommendHistoryList(recommendHistory);
		ExcelUtil<RecommendHistory> util = new ExcelUtil<RecommendHistory>(RecommendHistory.class);
		return util.exportExcel(list, "recommendhistory");
	}

	/**
	 * 新增热搜设置
	 */
	@GetMapping("/add")
	public String add() {
		return prefix + "/add";
	}

	/**
	 * 新增保存热搜设置
	 */
	@RequiresPermissions("game:recommendhistory:add")
	@Log(title = "热搜设置", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(RecommendHistory recommendHistory) {
		return toAjax(recommendHistoryService.insertRecommendHistory(recommendHistory));
	}

	/**
	 * 修改热搜设置
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap) {
		RecommendHistory recommendHistory = recommendHistoryService.selectRecommendHistoryById(id);
		mmap.put("recommendHistory", recommendHistory);
		return prefix + "/edit";
	}

	/**
	 * 修改保存热搜设置
	 */
	@RequiresPermissions("game:recommendhistory:edit")
	@Log(title = "热搜设置", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(RecommendHistory recommendHistory) {
		return toAjax(recommendHistoryService.updateRecommendHistory(recommendHistory));
	}

	/**
	 * 删除热搜设置
	 */
	@RequiresPermissions("game:recommendhistory:remove")
	@Log(title = "热搜设置", businessType = BusinessType.DELETE)
	@PostMapping("/remove")
	@ResponseBody
	public AjaxResult remove(String ids) {
		return toAjax(recommendHistoryService.deleteRecommendHistoryByIds(ids));
	}
}
